From 922855e245c8bdadc0d24b5b706549b18fb5f079 Mon Sep 17 00:00:00 2001
From: Alexander Egorenkov <egorenar-dev@posteo.net>
Date: Sat, 21 Nov 2020 11:08:56 +0100
Subject: [PATCH] kpartx, libmultipath: use pkg-config to get path to
 headers

Use pkg-config in Makefile to find path to devmapper and udev headers
to enable cross-compilation.

Signed-off-by: Alexander Egorenkov <egorenar-dev@posteo.net>
---
 kpartx/Makefile       |  2 +-
 libmultipath/Makefile | 12 ++++++------
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/kpartx/Makefile b/kpartx/Makefile
index 2906a984..29573890 100644
--- a/kpartx/Makefile
+++ b/kpartx/Makefile
@@ -8,7 +8,7 @@ LDFLAGS += $(BIN_LDFLAGS)
 
 LIBDEPS += -ldevmapper
 
-ifneq ($(call check_func,dm_task_set_cookie,/usr/include/libdevmapper.h),0)
+ifneq ($(call check_func,dm_task_set_cookie,$(shell $(PKG_CONFIG) --variable=includedir devmapper)/libdevmapper.h),0)
 	CFLAGS += -DLIBDM_API_COOKIE
 endif
 
diff --git a/libmultipath/Makefile b/libmultipath/Makefile
index 62ba16e8..3ad9130c 100644
--- a/libmultipath/Makefile
+++ b/libmultipath/Makefile
@@ -20,27 +20,27 @@ ifdef SYSTEMD
 	endif
 endif
 
-ifneq ($(call check_func,dm_task_no_flush,/usr/include/libdevmapper.h),0)
+ifneq ($(call check_func,dm_task_no_flush,$(shell $(PKG_CONFIG) --variable=includedir devmapper)/libdevmapper.h),0)
 	CFLAGS += -DLIBDM_API_FLUSH -D_GNU_SOURCE
 endif
 
-ifneq ($(call check_func,dm_task_get_errno,/usr/include/libdevmapper.h),0)
+ifneq ($(call check_func,dm_task_get_errno,$(shell $(PKG_CONFIG) --variable=includedir devmapper)/libdevmapper.h),0)
 	CFLAGS += -DLIBDM_API_GET_ERRNO
 endif
 
-ifneq ($(call check_func,dm_task_set_cookie,/usr/include/libdevmapper.h),0)
+ifneq ($(call check_func,dm_task_set_cookie,$(shell $(PKG_CONFIG) --variable=includedir devmapper)/libdevmapper.h),0)
 	CFLAGS += -DLIBDM_API_COOKIE
 endif
 
-ifneq ($(call check_func,udev_monitor_set_receive_buffer_size,/usr/include/libudev.h),0)
+ifneq ($(call check_func,udev_monitor_set_receive_buffer_size,$(shell $(PKG_CONFIG) --variable=includedir libudev)/libudev.h),0)
 	CFLAGS += -DLIBUDEV_API_RECVBUF
 endif
 
-ifneq ($(call check_func,dm_task_deferred_remove,/usr/include/libdevmapper.h),0)
+ifneq ($(call check_func,dm_task_deferred_remove,$(shell $(PKG_CONFIG) --variable=includedir devmapper)/libdevmapper.h),0)
 	CFLAGS += -DLIBDM_API_DEFERRED
 endif
 
-ifneq ($(call check_func,dm_hold_control_dev,/usr/include/libdevmapper.h),0)
+ifneq ($(call check_func,dm_hold_control_dev,$(shell $(PKG_CONFIG) --variable=includedir devmapper)/libdevmapper.h),0)
 	CFLAGS += -DLIBDM_API_HOLD_CONTROL
 endif
 
-- 
2.29.2

